using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

using VM.WebCore.SwaggerExtend;
using 迅火优选NetCore6接口;

namespace WeatherForecastTest.Controllers
{
    /// <summary>
    /// 天气预测接口类
    /// </summary>
    [ApiController]
   
    [Route("api/Log")]
    [ApiExplorerSettings(IgnoreApi = false, GroupName = nameof(ApiVersions.V1))]
    public class WeatherForecastController : ControllerBase
    {
        private static readonly string[] Summaries = new[]
        {
        "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
    };


        /// <summary>
        /// 天气预测接口
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        //[Authorize]//要求通过授权才行---只要能鉴权成功，都能通过]
        [Route("GetLog")]
        [ApiExplorerSettings(IgnoreApi = false, GroupName = nameof(ApiVersions.V1))]
        public IEnumerable<WeatherForecast> Get()
        {
            return Enumerable.Range(1, 5).Select(index => new WeatherForecast
            {
                Date = DateTime.Now.AddDays(index),
                TemperatureC = Random.Shared.Next(-20, 55),
                Summary = Summaries[Random.Shared.Next(Summaries.Length)]
            })
            .ToArray();
        }

        /// <summary>
        /// post接口
        /// </summary>
        /// <param name="a"></param>
        /// <returns></returns>
        [HttpPost]
        [Authorize]//要求通过授权才行---只要能鉴权成功，都能通过]
        [Route("AddLog")]
        [ApiExplorerSettings(IgnoreApi = false, GroupName = nameof(ApiVersions.V1))]
        public IEnumerable<WeatherForecast> Post(WeatherForecast a)
        {
            return Enumerable.Range(1, 5).Select(index => new WeatherForecast
            {
                Date = DateTime.Now.AddDays(index),
                TemperatureC = Random.Shared.Next(-20, 55),
                Summary = Summaries[Random.Shared.Next(Summaries.Length)]
            })
            .ToArray();
        }
    }
}